/*
 * File:    VariableContainer.java
 * Created: 10-Feb-2009
 * Version: $Id$
 * 
 * COPYRIGHT (C) 2009, Bitgate Mobile, LLC.  All Rights Reserved.
 *
 * software@bitgatemobile.com
 */

package com.webplasm.store;

public class VariableContainer {
	public enum VariableType {
		STRING  (com.webplasm.store.VariableStoreString.class),
		INTEGER	(com.webplasm.store.VariableStoreString.class),
		FLOAT	(com.webplasm.store.VariableStoreString.class),
		SQL	    (com.webplasm.store.VariableStoreSql.class),
		BOOLEAN	(com.webplasm.store.VariableStoreBoolean.class),
		MAP	    (com.webplasm.store.VariableStoreHash.class),
		HASHMAP (com.webplasm.store.VariableStoreHash.class),
		NODE	(com.webplasm.store.VariableStoreNode.class),
		XML		(com.webplasm.store.VariableStoreNode.class),
		ARRAY	(com.webplasm.store.VariableStoreArray.class);
		
		private final Class<?> variableStoreClass;
		
		private VariableType(Class<?> variableStoreClass) {
			this.variableStoreClass = variableStoreClass;
		}
		
		public VariableStoreInterface getVariableStoreInterface() {
			try {
				return (VariableStoreInterface) variableStoreClass.newInstance();
			} catch(Exception ex) {
				return null;
			}
		}
	}
	
	public VariableType variableType;
	public VariableStoreInterface variableStore;
	
	public VariableContainer(VariableType variableType) {
		this.variableType = variableType;
	}
	
	public VariableStoreInterface getVariableStoreInterface() {
		return variableStore;
	}
	
	public VariableType getType() {
		return variableType;
	}
}